package com.ys.vo;

/**
 * 审批格式数据
 * @author Jason
 *
 */
public class Flow {
	private Integer code;
	private Integer state;
	private String msg;
	
    public Flow() {
		super();
	}
	public Flow(Integer code, Integer state, String msg) {
		super();
		this.code = code;
		this.state = state;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	public enum Code {
    	
    	SUCCESS("成功", 0), FAILED("失败", 1);
    	public String name;
    	public Integer value;

    	private Code(String name, Integer value) {
    		this.name = name;
    		this.value = value;
    	}
    }
	
    public enum State {
    	
    	INIT("初始化", 0), PROCESS("进行中", 1), FINISH("已完成", 2);
    	public String name;
    	public Integer value;

    	private State(String name, Integer value) {
    		this.name = name;
    		this.value = value;
    	}
    }

    public static Flow ok(Integer state) {
    	Flow f = new Flow();
        f.setCode(Code.SUCCESS.value);
        f.setState(state);
        return f;
    }

    public static Flow error(String msg) {
    	Flow f = new Flow();
        f.setCode(Code.FAILED.value);
        f.setMsg(msg);
        return f;
    }
}